package com.sky.config;

import com.sky.utils.S3UploadUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.net.URI;

@Configuration
@Slf4j
public class S3Config {

    @Value("${s3.access-key}")
    private String accessKey;

    @Value("${s3.secret-key}")
    private String secretKey;

    @Value("${s3.endpoint}")
    private String endpoint;

    @Value("${s3.bucket-name}")
    private String bucketName;

    @Value("${s3.region}")
    private String region;

    @Bean
    @ConditionalOnMissingBean
    public S3UploadUtil s3UploadUtil() {
        log.info("初始化S3UploadUtil");
        log.info("初始化S3UploadUtil，endpoint: {}", endpoint);
        return new S3UploadUtil(endpoint, accessKey, secretKey, bucketName, region);
    }
}